home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 9.3 KB | 317 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: TblTrckr.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Table.hpp"
-
- #ifndef TBLTRCKR_H
- #include "TblTrckr.h"
- #endif
-
- #ifndef TBLPART_H
- #include "TblPart.h"
- #endif
-
- #ifndef TBLFRAME_H
- #include "TblFrame.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- // ----- OpenDoc Layer -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfTable
- #endif
-
- //========================================================================================
- // class CTableDropTracker
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CTableDropTracker::CTableDropTracker
- //----------------------------------------------------------------------------------------
-
- CTableDropTracker::CTableDropTracker(Environment* ev,
- CTablePart* part,
- CTableFrame* frame,
- ODFacet* facet,
- const CCell& sourceCell) :
- FW_CDropTracker(ev, frame, facet),
- fTableFrame(frame),
- fTablePart(part),
- fSourceCell(sourceCell),
- fCurCell(-1, -1)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTableDropTracker::~CTableDropTracker
- //----------------------------------------------------------------------------------------
-
- CTableDropTracker::~CTableDropTracker()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTableDropTracker::BeginTracking
- //----------------------------------------------------------------------------------------
-
- FW_CPoint CTableDropTracker::BeginTracking(Environment* ev,
- const FW_CPoint& anchorPoint)
- {
- CCell cell;
-
- if (fTablePart->HitTest(ev, fTableFrame, anchorPoint, cell) == kTLCell)
- Hilite(ev, cell, GetFacet(ev));
-
- return anchorPoint;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableDropTracker::ContinueTracking
- //----------------------------------------------------------------------------------------
-
- FW_CPoint CTableDropTracker::ContinueTracking(Environment* ev,
- const FW_CPoint& anchorPoint,
- const FW_CPoint& previousPoint,
- const FW_CPoint& currentPoint)
- {
- CCell cell;
- if (fTablePart->HitTest(ev, fTableFrame, currentPoint, cell) == kTLCell)
- Hilite(ev, cell, GetFacet(ev));
-
- return currentPoint;
- }
-
- //----------------------------------------------------------------------------------------
- // CTableDropTracker::Hilite
- //----------------------------------------------------------------------------------------
-
- void CTableDropTracker::Hilite(Environment* ev, const CCell& cell, ODFacet* facet)
- {
- if (cell == fCurCell)
- return;
-
- #ifdef FW_BUILD_MAC
- this->HideDragHilite(ev);
-
- FW_CWindowContext gc(ev, facet); // focus drawing to the window
-
- DragReference theDrag = fTablePart->GetSession(ev)->GetDragAndDrop(ev)->GetDragReference(ev);
-
- if (cell != fSourceCell)
- {
- fCurCell = cell;
-
- FW_CRect cellRect;
- fTablePart->FindRect(cell, cellRect);
-
- FW_CRect shapeBounds = fTableFrame->GetBounds(ev);
- FW_CAcquiredODTransform aqInternalXForm = fTableFrame->AcquireInternalTransform(ev, NULL);
- shapeBounds.Transform(ev, aqInternalXForm);
- cellRect.Intersection(shapeBounds);
-
- FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, cellRect);
-
- this->ShowDragHilite(ev, aqShape, TRUE);
- }
- #endif
- }
-
- //========================================================================================
- // class CGridLineTracker
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CGridLineTracker constructor
- //----------------------------------------------------------------------------------------
- CGridLineTracker::CGridLineTracker(Environment* ev,
- FW_CView* view,
- ODFacet* facet,
- ETableLoc tl,
- FW_CRect dragArea,
- FW_CPoint borders) :
- FW_CTracker(ev, view, facet),
- fDragArea(dragArea),
- fOldBorders(borders),
- fNewBorders(borders),
- fCross(borders, dragArea.BotRight())
- {
- // Get direction of resize
- fHorizMove = ((tl & (kTLLeftBorder + kTLRightBorder)) != 0);
- fVertMove = ((tl & (kTLTopBorder + kTLBottomBorder)) != 0);
-
- if (fHorizMove)
- fCross.SetVLineToMove();
- if (fVertMove)
- fCross.SetHLineToMove();
- }
-
- //----------------------------------------------------------------------------------------
- // CGridLineTracker destructor
- //----------------------------------------------------------------------------------------
- CGridLineTracker::~CGridLineTracker()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CGridLineTracker::BeginTracking
- //----------------------------------------------------------------------------------------
- FW_CPoint CGridLineTracker::BeginTracking(Environment* ev,
- const FW_CPoint& anchorPoint)
- {
- // Display borders that are moving
- FW_CViewContext vc(ev, GetView(ev), GetFacet(ev));
- fCross.Render(vc);
-
- return anchorPoint;
- }
-
- //----------------------------------------------------------------------------------------
- // CGridLineTracker::ContinueTracking
- //----------------------------------------------------------------------------------------
- FW_CPoint CGridLineTracker::ContinueTracking(Environment* ev,
- const FW_CPoint& anchorPoint,
- const FW_CPoint& previousPoint,
- const FW_CPoint& currentPoint)
- {
- FW_UNUSED(anchorPoint);
- FW_CPoint now(currentPoint);
-
- // Stay in permissible drag area
- if (now.x < fDragArea.left)
- now.x = fDragArea.left;
- if (now.x > fDragArea.right)
- now.x = fDragArea.right;
- if (now.y < fDragArea.top)
- now.y = fDragArea.top;
- if (now.y > fDragArea.bottom)
- now.y = fDragArea.bottom;
-
- // Move the borders
- if (now != previousPoint)
- {
- FW_CFixed x = (fHorizMove ? now.x - previousPoint.x : FW_IntToFixed(0));
- FW_CFixed y = (fVertMove ? now.y - previousPoint.y : FW_IntToFixed(0));
-
- FW_CViewContext vc(ev, GetView(ev), GetFacet(ev));
- fCross.Render(vc);
- fCross.MoveShape(x, y);
- fCross.Render(vc);
-
- fNewBorders.x += x;
- fNewBorders.y += y;
- }
-
- return now;
- }
-
- //----------------------------------------------------------------------------------------
- // CGridLineTracker::EndTracking
- //----------------------------------------------------------------------------------------
- FW_Boolean CGridLineTracker::EndTracking(Environment* ev,
- const FW_CPoint& anchorPoint,
- const FW_CPoint& lastPoint)
- {
- // Restore the borders
- FW_CViewContext vc(ev, GetView(ev), GetFacet(ev));
- fCross.Render(vc);
-
- return anchorPoint != lastPoint;
- }
-
- //========================================================================================
- // class CCrossShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CCrossShape::CCrossShape
- //----------------------------------------------------------------------------------------
-
- CCrossShape::CCrossShape(const FW_CPoint& brCell, FW_CPoint& brFrm)
- : vLine(brCell.x, kHMargin, brCell.x, brFrm.y),
- hLine(kVMargin, brCell.y, brFrm.x, brCell.y)
- {
- vLine.SetInk(FW_kInvertInk);
- hLine.SetInk(FW_kInvertInk);
-
- vLine.SetRenderVerb(FW_kNoRendering);
- hLine.SetRenderVerb(FW_kNoRendering);
- }
-
- //----------------------------------------------------------------------------------------
- // CCrossShape::Render
- //----------------------------------------------------------------------------------------
-
- void CCrossShape::Render(FW_CGraphicContext& graphicContext)
- {
- vLine.Render(graphicContext);
- hLine.Render(graphicContext);
- }
-
- //----------------------------------------------------------------------------------------
- // CCrossShape::MoveShape
- //----------------------------------------------------------------------------------------
-
- void CCrossShape::MoveShape(FW_CFixed deltaX, FW_CFixed deltaY)
- {
- vLine.MoveShape(deltaX, FW_IntToFixed(0));
- hLine.MoveShape(FW_IntToFixed(0), deltaY);
- }
-
- //----------------------------------------------------------------------------------------
- // CCrossShape::SetHLineToMove
- //----------------------------------------------------------------------------------------
-
- void CCrossShape::SetHLineToMove()
- {
- hLine.SetRenderVerb(FW_kFrame);
- }
-
- //----------------------------------------------------------------------------------------
- // CCrossShape::SetVLineToMove
- //----------------------------------------------------------------------------------------
-
- void CCrossShape::SetVLineToMove()
- {
- vLine.SetRenderVerb(FW_kFrame);
- }
-
-
-